package cn.wolfcode.trip.base.domain;
/**
 * 攻略评论类
 */

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Getter@Setter
public class StrategyComment extends BaseDomain{
    public static final int STATE_REJECT=0;//点评拒绝状态
    public static final int STATE_NORMAL=1;//点评发布状态

    private User user;//评论用户
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8" )
    private Date createTime;//评论时间

    private String content;//评论内容

    private String imgUrls;//评论图片

    private Integer starNum;//评论星星数

    private Strategy strategy;//评论的攻略

    private Integer state=STATE_NORMAL;//评论的状态
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8" )
    private Date commendTime;//评论发布的时间

    private  String[] tagNames;//标签
    //返回图片的数组--后台显示图片的时候返回数组
    public String[] getImgArray() {
        if (StringUtils.hasLength(imgUrls)) {
            return imgUrls.split(";");
        }
        return null;
    }

    public String getStateDisplay(){
        if(state!=null){
            if(state==STATE_REJECT){
                return "拒绝";
            }else if(state==STATE_NORMAL){
                return "发布";
            }
        }
        return "";
    }
}